403Webshell
Server IP : 121.121.20.254  /  Your IP : 216.73.216.202
Web Server : Microsoft-IIS/10.0
System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64
User : IUSR ( 0)
PHP Version : 8.3.28
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Program Files/LibreOffice/help/en-US/text/sbasic/shared/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Program Files/LibreOffice/help/en-US/text/sbasic/shared/03090202.html
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<base href="../../../../">
<noscript><meta http-equiv="refresh" content="0; URL=../../../../en-US/noscript.html"></noscript>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>For...Next Statement</title>
<link rel="shortcut icon" href="media/navigation/favicon.ico">
<link type="text/css" href="normalize.css" rel="Stylesheet">
<link type="text/css" href="prism.css" rel="Stylesheet">
<link type="text/css" href="default.css" rel="Stylesheet">
<script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="languages.js"></script><script type="text/javascript" src="en-US/langnames.js"></script><script type="text/javascript" src="flexsearch.debug.js"></script><script type="text/javascript" src="prism.js"></script><script type="text/javascript" src="help2.js" defer></script><script type="text/javascript" src="a11y-toggle.js" defer></script><script type="text/javascript" src="paginathing.js" defer></script><script type="text/javascript" src="en-US/bookmarks.js" defer></script><script type="text/javascript" src="en-US/contents.js" defer></script><script type="text/javascript" src="help.js" defer></script><meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<header id="TopLeftHeader"><a class="symbol" href="en-US/text/shared/05/new_help.html"><div></div></a><a class="logo" href="en-US/text/shared/05/new_help.html"><p dir="auto">LibreOffice 24.2 Help</p></a><div class="dropdowns"><div class="modules">
<button type="button" data-a11y-toggle="modules-nav" id="modules" aria-haspopup="true" aria-expanded="false" aria-controls="modules-nav">Module</button><nav id="modules-nav" hidden=""></nav>
</div></div></header><aside class="leftside"><input id="accordion-1" name="accordion-menu" type="checkbox"><label for="accordion-1" dir="auto">Contents</label><div id="Contents" class="contents-treeview"></div></aside><div id="SearchFrame"><div id="Bookmarks">
<input id="search-bar" type="search" class="search" placeholder="Search in bookmarks for chosen module" dir="auto"><div class="nav-container" tabindex="0"><nav class="index" dir="auto"></nav></div>
</div></div>
<div id="DisplayArea" itemprop="softwareHelp" itemscope="true" itemtype="http://schema.org/SoftwareApplication">


<a name="fornext"></a>
<a name="bm_id3149205"></a>
<meta itemprop="keywords" content="For statement">
<meta itemprop="keywords" content="For Each statement">
<meta itemprop="keywords" content="In keyword">
<meta itemprop="keywords" content="Next keyword">
<meta itemprop="keywords" content="Step keyword">
<meta itemprop="keywords" content="To keyword">



<h1 id="hd_id3149205" dir="auto">For...Next Statement</h1>
  <p id="par_id3143267" class="paragraph" dir="auto">Repeats the statements between the <span class="literal">For...Next</span> block a specified number of times.</p>


<h2 id="hd_id3156153" dir="auto">Syntax:</h2>
<p id="par_id491585753339474" class="paragraph" dir="auto">
  <img src="media/helpimg/sbasic/For-Next_statement.svg" class="genericimage" alt="For Statement diagram" style="width:;height:" itemprop="image" itemscope="true" itemtype="http://schema.org/ImageObject">
</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
For counter=start To end [Step step]
    statement-block
    [Exit For]
    statement-block
Next [counter]
</code></pre></div>
<p id="par_id491585653339474" class="paragraph" dir="auto">
  <img src="media/helpimg/sbasic/For-Each_statement.svg" class="genericimage" alt="For Each Statement diagram" style="width:;height:" itemprop="image" itemscope="true" itemtype="http://schema.org/ImageObject">
</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
  For Each item In list
      statement-block
  [Exit For]
      statement-block
  Next [item]
</code></pre></div>

<h2 id="hd_id3150400" dir="auto">Variables:</h2>
<p id="par_id3150358" class="paragraph" dir="auto"> <span class="emph">counter:</span> Loop <span class="literal">counter</span> initially assigned the value to the right of the equal sign (<span class="literal">start</span>). Only numeric variables are valid. The loop counter increases or decreases according to the variable <span class="literal">step</span> until <span class="literal">end</span> is passed.</p>
<p id="par_id3152455" class="paragraph" dir="auto"> <span class="emph">start:</span> Numeric variable that defines the initial value at the beginning of the loop.</p>
<p id="par_id3151043" class="paragraph" dir="auto"> <span class="emph">end:</span> Numeric variable that defines the final value at the end of the loop.</p>
<p id="par_id3156281" class="paragraph" dir="auto"> <span class="emph">step:</span> Sets the value by which to increase or decrease the loop counter. If <span class="literal">step</span> is not specified, the loop counter is incremented by 1. In this case, <span class="literal">end</span> must be greater than <span class="literal">start</span>. If you want to decrease <span class="literal">counter</span>, <span class="literal">end</span> must be less than <span class="literal">start</span>, and <span class="literal">step</span> must be assigned a negative value.</p>
<p id="par_id3154684" class="paragraph" dir="auto">The <span class="emph">For...Next</span> loop repeats all of the statements in the loop for the number of times that is specified by the parameters.</p>
<p id="par_id3147287" class="paragraph" dir="auto">As the <span class="literal">counter</span> variable is decreased, LibreOffice Basic checks if the <span class="literal">end</span> value has been reached. As soon as the <span class="literal">counter</span> passes the <span class="literal">end</span> value, the loop automatically terminates.</p>
<p id="par_id3159154" class="paragraph" dir="auto">It is possible to nest <span class="emph">For...Next</span> statements. If you do not specify a variable following the <span class="emph">Next</span> statement, <span class="emph">Next</span> automatically refers to the most recent <span class="emph">For</span> statement.</p>
<p id="par_id3155306" class="paragraph" dir="auto">If you specify an increment of 0, the statements between <span class="emph">For</span> and <span class="emph">Next</span> are repeated continuously.</p>
<p id="par_id3155854" class="paragraph" dir="auto">When counting down the counter variable, LibreOffice Basic checks for overflow or underflow. The loop ends when <span class="literal">counter</span> exceeds <span class="literal">end</span> (positive Step value) or is less than <span class="literal">end</span> (negative Step value).</p>
<p id="par_id3145273" class="paragraph" dir="auto">Use the <span class="emph">Exit For</span> statement to exit the loop unconditionally. This statement must be within a <span class="emph">For...Next</span> loop. Use the <span class="emph">If...Then</span> statement to test the exit condition as follows:</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
  For...
      statement-block
      If condition = True Then Exit For
      statement-block
  Next
</code></pre></div>

<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id3156286" dir="auto">In nested <span class="emph">For...Next</span> loops, if you exit a loop unconditionally with <span class="emph">Exit For</span>, only one loop is exited.</p></div>
</div>
<br>

<h2 id="hd_id3148457" dir="auto">Examples</h2>
<p id="par_id3151074" class="paragraph" dir="auto">The following example uses two nested loops to sort a string array with 10 elements ( sEntry() ), that is filled with various contents:</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
Sub ExampleSort
Dim sEntry(9) As String
Dim iCount As Integer, iCount2 As Integer
Dim sTemp As String
    sEntry = Array("Jerry","Patty","Kurt","Thomas","Michael",_
                 "David","Cathy","Susie","Edward","Christine")
    For iCount = 0 To 9
        For iCount2 = iCount + 1 To 9
            If sEntry(iCount) &gt; sEntry(iCount2) Then
                sTemp = sEntry(iCount)
                sEntry(iCount) = sEntry(iCount2)
                sEntry(iCount2) = sTemp
            End If
        Next iCount2
    Next iCount
    For iCount = 0 To 9
        Print sEntry(iCount)
    Next iCount
End Sub
</code></pre></div>
<p id="par_id561586524231943" class="paragraph" dir="auto">This explores the content of an array to display each item it contains.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
  Sub list_iteration
      cutlery = Array("fork", "knife", "spoon")
      For Each item in cutlery
          Print item
      Next ' item
  End Sub
</code></pre></div>
</div>
<div id="DonationFrame"></div>
<footer><div id="DEBUG" class="debug">
<h3 class="bug">Help content debug info:</h3>
<p dir="auto">This page is: <a href="https://opengrok.libreoffice.org/xref/help/source/text/sbasic/shared/03090202.xhp" target="_blank">/text/sbasic/shared/03090202.xhp</a></p>
<p dir="auto">Title is: For...Next Statement</p>
<p id="bm_module" dir="auto"></p>
<p id="bm_system" dir="auto"></p>
<p id="bm_HID" dir="auto"></p>
</div></footer>
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit